//package com.com.wss.service.user.handler;
//
//
//import com.com.wss.common.utils.DateUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.security.authentication.AuthenticationProvider;
//import org.springframework.security.authentication.InternalAuthenticationServiceException;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.core.userdetails.UserDetails;
//
//import java.time.LocalDateTime;
//
//@Slf4j
//public class UserIdAuthenticationProvider implements AuthenticationProvider {
//
//    private ZltUserDetailsService userDetailsService;
//
//    @Override
//    public Authentication authenticate(Authentication authentication) {
//        Long timeSpan = DateUtil.getTimeSpan(LocalDateTime.now());
//
//        UserIdAuthenticationToken authenticationToken = (UserIdAuthenticationToken) authentication;
//        Long userId = (Long) authenticationToken.getPrincipal();
//        Long timeSpan1 =DateUtil.getTimeSpan(LocalDateTime.now())-timeSpan;
//        timeSpan = DateUtil.getTimeSpan(LocalDateTime.now());
//        log.info("----login---211--"+"----"+timeSpan1+"-----"+timeSpan);
//        UserDetails user = userDetailsService.loadUserByUserId(userId);
//        timeSpan1 =DateUtil.getTimeSpan(LocalDateTime.now())-timeSpan;
//        timeSpan = DateUtil.getTimeSpan(LocalDateTime.now());
//        log.info("----login---212--"+"----"+timeSpan1+"-----"+timeSpan);
//        if (user == null) {
//            throw new InternalAuthenticationServiceException("userId错误");
//        }
//        UserIdAuthenticationToken authenticationResult = new UserIdAuthenticationToken(user, user.getAuthorities());
//        authenticationResult.setDetails(authenticationToken.getDetails());
//        return authenticationResult;
//    }
//
//    @Override
//    public boolean supports(Class<?> authentication) {
//        return UserIdAuthenticationToken.class.isAssignableFrom(authentication);
//    }
//
//    public ZltUserDetailsService getUserDetailsService() {
//        return userDetailsService;
//    }
//
//    public void setUserDetailsService(ZltUserDetailsService userDetailsService) {
//        this.userDetailsService = userDetailsService;
//    }
//}
//
